<div class="layuimini-container layui-anim layui-anim-upbit">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>上传工作流文件</legend>
            <div style="margin: 10px 10px 10px 10px">
                <div class="layui-upload">
				  <button type="button" class="layui-btn layui-btn-normal" id="chooseBtn">选择文件</button>
				  <button type="button" class="layui-btn" id="uploadBtn">开始上传</button>
				</div>
            </div>
        </fieldset>

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
        </script>

    </div>
</div>

<script>
	layui.use(['form', 'table','layuimini','element'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            layuimini = layui.layuimini;
            
        table.render({
            elem: '#currentTableId',
            url: 'getProcessList',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [
		            [
		                {field: 'id', width: 200, title: 'ID'},
		                {field: 'deploymentId', width: 120, title: '部署ID'},
		                {field: 'name', width: 150, title: '部署名称'},
		                {field: 'resourceName', width: 200, title: '资源地址'},
		                {field: 'key', title: '部署key', width: 170},
		                {field: 'diagramresourcename', width: 200, title: 'diagramresourcename'},
		                {title: '操作', minWidth: 50, templet: '#currentTableBar', fixed: "right", align: "center"}
		            ]
            ],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true
        });
        
        // 监听删除操作
	    table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'delete') {
                layer.confirm('真的删除行么', function (index) {
                    $.ajax({
			             url:"deleteDeploy",
			             type:'post',
			             data:{
			             	"deployId":data.deploymentId
			             },
			             success:function(data){
			             	
							layer.close(index);
							//执行搜索重载
				            table.reload('currentTableId', {
				                page: {
				                    curr: 1
				                }
				            });
			             }
		              
		            });
                });
            }
        });
    });
    
    //文件上传
    layui.use('upload', function(){
    	var $ = layui.jquery;
    	var upload = layui.upload;
    	//选完文件后不自动上传
		upload.render({
		    elem: '#chooseBtn',
		    url: 'uploadWorkflow', //改成您自己的上传接口
		    accept: 'file', //普通文件
		    auto: false,
		    multiple: false,
		    bindAction: '#uploadBtn',
		    done: function(res){
		      	layer.msg('上传成功');
		    }
		});
    });
    
</script>